import { getArrayItem, getDistance } from "../utils/utls"
import { DamageChangeData } from "../全局对象/DamageManage"
import { MoneyEnum, PriceType } from "./基础配置"

export const MaxStrengSkillLevel = 10

export const StrengSkillList = [
    [
        {
            skillName: '攻杀剑术',
            priceName: "defaultPrice"
        },
        {
            skillName: '半月弯刀',
            priceName: "defaultPrice"
        },
        {
            skillName: '刺杀剑术',
            priceName: "defaultPrice"
        },
        {
            skillName: '烈火剑法',
            priceName: "pirce1"
        },
    ],
    [
        {
            skillName: '诱惑之光',
            priceName: "defaultPrice"
        },
        {
            skillName: '雷电术',
            priceName: "defaultPrice"
        },
        {
            skillName: '魔法盾',
            priceName: "defaultPrice"
        },
        {
            skillName: '冰咆哮',
            priceName: "pirce1"
        },
    ],
    [
        {
            skillName: '灵魂火符',
            priceName: "defaultPrice"
        },
        {
            skillName: '施毒术',
            priceName: "defaultPrice"
        },
        {
            skillName: '召唤骷髅',
            priceName: "defaultPrice"
        },
        {
            skillName: '召唤神兽',
            priceName: "pirce1"
        },
    ],
]


export const StrengSkillPrice = {
    "defaultPrice": [
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 5
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 10
            }
        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 10
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 20
            }
        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 20
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 50
            }
        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 50
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 100
            }
        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 50
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 1
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 100
            },

        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 50
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 2
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 100
            },

        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 100
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 4
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 200
            },

        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 100
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 8
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 200
            },

        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 100
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 16
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 200
            },

        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 100
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 32
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 200
            },

        ],
    ],
    "pirce1": [
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 10
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 2
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 20
            }
        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 20
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 4
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 40
            }
        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 40
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 8
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 80
            }
        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 80
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 16
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 160
            }
        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 80
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 20
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 200
            }
        ],
        [
            {
                type: PriceType.Item,
                name: '书页',
                num: 100
            },
            {
                type: PriceType.Item,
                name: '技能神石',
                num: 40
            },
            {
                type: PriceType.Money,
                name: MoneyEnum.GameGold,
                num: 200
            }
        ]
    ],
}
// export const StrengSkillPower=[
//     'default':[
//         3,6,9,12,15,18,21,24,
//     ]
// ]

export const ShieldSkillCut = [
    300,
    700,
    1100,
    1500,
]

const ShieldAddSkill = [
    "刺杀剑术", "开天斩", "逐日剑法"
]

const ShieldAddDamagePer = 1500;

//检查技能是否对魔法盾有额外伤害
export function checkAddShieldDamage(ActorObject: TActor, ADamageSource: TActor, skillName: string): DamageChangeData {
    let flag = false;
    //刺杀破盾要检查是不是刺杀位
    if (skillName === '刺杀剑术') {
        if (ActorObject.Map.MapID === ADamageSource.Map.MapID) {
            let x = Math.abs(ADamageSource.MapX - ActorObject.MapX)
            let y = Math.abs(ADamageSource.MapY - ActorObject.MapY)
            if ((x === 0 && y === 2) || (x === 2 && y === 0) || (x === 2 && y === 2)) {
                flag = true
            }
        }

    }
    else if (ShieldAddSkill.includes(skillName)) {
        flag = true;
    }
    if (flag) {
        let data: DamageChangeData = new DamageChangeData();
        data.addPercent = ShieldAddDamagePer;
        return data
    }
    return null;
}

//获取魔法盾减伤
export function getShieldPower(magice: TUserMagic): number {
    if (!magice) {
        return 0
    }

    let lv = magice.Level;
    let level = magice.GetStrengthen();
    if (lv < 3) {
        return getArrayItem(ShieldSkillCut, lv)
    }
    else {
        return getArrayItem(ShieldSkillCut, 3) + level * 60
    }

}

export function getStrengSkillPower(magice: TUserMagic): number {
    if (!magice) {
        return 0
    }
    let add = 0;

    let level = magice.GetStrengthen();
    return level * 50 + add;
}